package com.gitee.srurl.core.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author zxw
 * @date 2023/4/29 17:21
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("sus_visitor_record")
public class SusVisitorRecordDomain implements Serializable {

    @Serial
    private static final long serialVersionUID = -3409339753807851304L;

    @TableId(type = IdType.INPUT)
    private Long id;

    /**
     * 短链Id
     */
    private String shortId;

    /**
     * 原始url
     * originUrl 和 shortUrl 其实可以不存储 但是存储的记录设计的是可以替换 非mysql 不使用mysql的话没法通过关联表查出来
     */
    private String originUrl;

    /**
     * 短链url
     */
    private String shortUrl;

    /**
     * 访问时间
     */
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime visitTime;

    /**
     * 客户端操作系统
     */
    private String os;

    /**
     * 客户端浏览器
     */
    private String browser;

    /**
     * 请求IP
     */
    private String ip;
}
